const attr = {
	s: 'solid',
	do: 'dotted',
	da: 'dashed',
	db: 'double'
}

const ori = {
	l: '-left',
	t: '-top',
	b: '-bottom',
	r: '-right'
}

const Re = /(bd)([xytlbr]|lt|tb|rt|rb)?(\d+)?(s|do|da|db)?([abcdef\d]{3,6})?/g

const bd = (str)=>{
	let arrClass = str.match(Re)
	if (arrClass === null) return ''
	return arrClass.join('\n').replace(Re, (...args)=>{
		let [cn, suf, di, size=1, type, color='000'] = args
		di = di ? ori[di] : ''
		type = type ? attr[type] : 'solid'
		return `.${cn}{border${di}: ${size}px ${type} #${color};}`
	})
}

module.exports = bd